/**
 * @param {number[]} nextVisit
 * @return {number}
 * 你需要访问 n 个房间，房间从 0 到 n - 1 编号。同时，每一天都有一个日期编号，从 0 开始，依天数递增。你每天都会访问一个房间。
 */

// 模拟过程，最笨但是最直接的解法
var one = function(nextVisit) {
    const len = nextVisit.length
    const mod = 1e9 + 7
    const visitedList = [1]
    const roomList = [0]
    let visited = 0 // 访问房间
    let res = 1 // 天数
    let room = 0
    for (; visited !== len; res++) {
        room = (visitedList[room] % 2) ? nextVisit[room] : (room + 1) % len
        if (!roomList.includes(room)) roomList.push(room)
        visited = roomList.length
        visitedList[room] ? visitedList[room]++ : visitedList[room] = 1
        console.log(room, visitedList)
    }
    return (res - 1) % mod
};
// 尝试优化，开始找规律
var firstDayBeenInAllRooms = function(nextVisit) {
    // 查看 nextVisit  的最大值，
    let max = 0
    nextVisit.forEach(item => max = Math.max(item, max))
    console.log(max)
    // 先通过 正常模式，找到 数组中最大数组， 这样能快速定位最大房间号，然后
};
const nextVisit = [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]
console.log(firstDayBeenInAllRooms(nextVisit))
// const res =2 
// console.log( (res % 2) ? nextVisit[res] : (res + 1) % 2)